home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Mail / pine3.92 / pico / mswin.h < prev    next >
C/C++ Source or Header  |  1996-03-17  |  9KB  |  325 lines

  1. #line 2 "mswin.h"
  2. /*
  3.  *
  4.  * Program:    Operating system dependent routines - Microsoft Windows 3.1
  5.  *
  6.  *
  7.  * Thomas Unger
  8.  * Networks and Distributed Computing
  9.  * Computing and Communications
  10.  * University of Washington
  11.  * Administration Builiding, AG-44
  12.  * Seattle, Washington, 98195, USA
  13.  * Internet: tunger@cac.washington.edu
  14.  *
  15.  * Please address all bugs and comments to "pine-bugs@cac.washington.edu"
  16.  *
  17.  *
  18.  * Pine and Pico are registered trademarks of the University of Washington.
  19.  * No commercial use of these trademarks may be made without prior written
  20.  * permission of the University of Washington.
  21.  * 
  22.  * Pine, Pico, and Pilot software and its included text are Copyright
  23.  * 1989-1996 by the University of Washington.
  24.  * 
  25.  * The full text of our legal notices is contained in the file called
  26.  * CPYRIGHT, included with this distribution.
  27.  */
  28.  
  29.  
  30. #ifndef MSWIN_H
  31. #define MSWIN_H
  32.  
  33.  
  34. /*
  35.  * Def's to help Win32 port...
  36.  */
  37. #ifdef    WIN32
  38. #define    __far
  39. #define    _far
  40. #define    __export
  41. #define    signal    mswin_signal
  42. #endif
  43.  
  44.  
  45. /*
  46.  * Equivalent to a windows handle.
  47.  */
  48. #ifdef    WIN32
  49. typedef void           *WINHAND;
  50. #else
  51. typedef unsigned int    WINHAND;
  52. #endif
  53.  
  54. /*
  55.  * Mouse input events. 
  56.  */
  57. typedef struct {
  58.     int        event;
  59.     int        button;
  60.     int        nRow;
  61.     int        nColumn;
  62.     int        keys;
  63.     int        flags;
  64. } MEvent;
  65.  
  66.  
  67. /*
  68.  * These define how mouse events get queued.
  69.  */
  70. #define MSWIN_MF_REPLACING    0x1000
  71. #define MSWIN_MF_REPEATING    0x2000
  72.  
  73.  
  74. typedef struct {
  75.     int        ch;
  76.     int        rval;
  77.     char        *name;
  78.     char        *label;
  79.     int        id;
  80. } MDlgButton;
  81.  
  82.  
  83.  
  84. /*
  85.  * Type of function expected by mswin_allowcopy and mswin_allowcopycut
  86.  * and used in EditDoCopyData
  87.  */
  88. typedef    int (*getc_t)(int pos);
  89.  
  90. /*
  91.  * Type used by line up/down event handlers to move the body of the
  92.  * displayed text.
  93.  */
  94. typedef int (*scroll_t)(int action, long count);
  95.  
  96. /*
  97.  * Callback used to fetch text for display in alternate window.  Text
  98.  * can be returned as either a pointer to a null terminated block of
  99.  * text (a string), with CRLF deliminating lines.  OR as a pointer to
  100.  * an array of pointers to lines, each line being a null terminated
  101.  * string. 
  102.  */
  103. typedef int (*gettext_t)(char *title, void **text, long *len, int *format);
  104.  
  105.  
  106. /*
  107.  * Callback used for periodic callback.
  108.  */
  109. typedef void (*callback_t)(void);
  110.  
  111. #define GETTEXT_TITLELEN    128
  112. #define GETTEXT_TEXT        1    /* 'text' is pointer to text. */
  113. #define GETTEXT_LINES        2    /* 'text' is pointer to array of
  114.                      *   pointers to lines. */
  115.  
  116.  
  117. #define PATH_MAX        128    /* Max size of a directory path. */
  118.  
  119.  
  120. #define MSWIN_RANGE_START    0x7001
  121. #define MSWIN_KEY_UP        0x7001
  122. #define MSWIN_KEY_DOWN        0x7002
  123. #define MSWIN_KEY_RIGHT        0x7003
  124. #define MSWIN_KEY_LEFT        0x7004
  125. #define MSWIN_KEY_PREVPAGE    0x7005
  126. #define MSWIN_KEY_NEXTPAGE    0x7006
  127. #define MSWIN_KEY_HOME        0x7007
  128. #define MSWIN_KEY_END        0x7008
  129. #define MSWIN_KEY_DELETE    0x7009
  130. #define MSWIN_KEY_F1        0x700a
  131. #define MSWIN_KEY_F2        0x700b
  132. #define MSWIN_KEY_F3        0x700c
  133. #define MSWIN_KEY_F4        0x700d
  134. #define MSWIN_KEY_F5        0x700e
  135. #define MSWIN_KEY_F6        0x700f
  136. #define MSWIN_KEY_F7        0x7010
  137. #define MSWIN_KEY_F8        0x7011
  138. #define MSWIN_KEY_F9        0x7012
  139. #define MSWIN_KEY_F10        0x7013
  140. #define MSWIN_KEY_F11        0x7014
  141. #define MSWIN_KEY_F12        0x7015
  142. #define MSWIN_KEY_NODATA    0x7016
  143. #define MSWIN_KEY_SCROLLUPLINE        0x7017
  144. #define MSWIN_KEY_SCROLLDOWNLINE    0x7018
  145. #define MSWIN_KEY_SCROLLUPPAGE        0x7019
  146. #define MSWIN_KEY_SCROLLDOWNPAGE    0x701a
  147. #define MSWIN_KEY_SCROLLTO        0x701b
  148.  
  149. #define MSWIN_RANGE_END        0x701b
  150.  
  151. #define    MSWIN_PASTE_DISABLE    0
  152. #define    MSWIN_PASTE_FULL    1
  153. #define    MSWIN_PASTE_LINE    2
  154.  
  155.  
  156. #define MSWIN_CURSOR_ARROW    0
  157. #define MSWIN_CURSOR_BUSY    1
  158.  
  159. /*
  160.  * Flags for mswin_displaytext
  161.  */
  162. #define MSWIN_DT_NODELETE    0x0001    /* Don't delete text when 
  163.                      * window closes. */
  164.  
  165.  
  166.  
  167. /*
  168.  * functions from mswin.c
  169.  */
  170.  
  171. #define assert(x)    if (!(x)) AssertFail (#x, __FILE__, __LINE__, 1);
  172. void            AssertFail    (char *str, char *file, int line, int msgbox);
  173.  
  174. WINHAND        mswin_gethinstance();
  175. WINHAND        mswin_gethwnd ();
  176. int        mswin_getmouseevent (MEvent * pMouse);
  177. int        mswin_setdebug (int debug, FILE *debugfile);
  178. int        mswin_setdndcallback (int (*cb)());
  179. int        mswin_cleardndcallback (void);
  180. int        mswin_setresizecallback (int (*cb)());
  181. int        mswin_clearresizecallback (int (*cb)());
  182. int        mswin_sethelptext (char *title, char *pHelpText, 
  183.             size_t len, char **pHelpLines);
  184. int        mswin_setclosetext (char *pCloseText);
  185. int        mswin_setwindow (char *fontName, char *fontSize, 
  186.             char *fontStyle, char *windowPosition);
  187. int        mswin_getwindow (char *fontName, char *fontSize, 
  188.             char *fontStyle, char *windowPosition);
  189. void        mswin_setscrollrange (long max);
  190. void        mswin_setscrollpos (long pos);
  191. long        mswin_getscrollpos (void);
  192. long        mswin_getscrollto (void);
  193. void        mswin_setscrolcallback (scroll_t);
  194. int        mswin_setprintfont (char *fontName, char *fontSize, 
  195.             char *fontStyle);
  196. int        mswin_getprintfont (char *fontName, char *fontSize, 
  197.             char *fontStyle);
  198. int        mswin_yeild (void);
  199. int        mswin_charavail (void);
  200. int        mswin_getc (void);
  201. int        mswin_getc_fast (void);
  202. int        mswin_open (void);
  203. int        mswin_close (void);
  204. int        mswin_showcursor (int show);
  205. int        mswin_move (int row, int column);
  206. int        mswin_getpos (int *row, int *column);
  207. int        mswin_getscreensize (int *row, int *column);
  208. int        mswin_putblock (char *str, int strLen);
  209. int        mswin_puts (char *str);
  210. int        mswin_putc (int c);
  211. int        mswin_outc (char c);
  212. int        mswin_delchar (void);
  213. int        mswin_inschar (int c);
  214. int        mswin_rev (int state);
  215. int        mswin_getrevstate (void);
  216. int        mswin_eeol (void);
  217. int        mswin_eeop (void);
  218. int        mswin_beep (void);
  219. int        mswin_pause (int);
  220. int        mswin_flush (void);
  221. void        mswin_setcursor (int);
  222. int        mswin_messagebox (char *msg);
  223. int        mswin_allowpaste (int);
  224. int        mswin_allowcopycut (getc_t);
  225. int        mswin_allowcopy (getc_t);
  226. int        mswin_newmailicon (void);
  227. void        mswin_menuitemclear (void);
  228. void        mswin_menuitemadd (int key, char *label, int menuitem, 
  229.             int flags);
  230. int        mswin_setwindowmenu (int menu);
  231. int        mswin_print_ready (WINHAND hWnd, char *docDesc);
  232. int        mswin_print_done (void);
  233. char *        mswin_print_error (int errorcode);
  234. int        mswin_print_char (int c);
  235. int        mswin_print_text (char *text);
  236. int        mswin_savefile (char *dir, char *fName, int nMaxFName);
  237. int        mswin_openfile (char *dir, char *fName, int nMaxFName);
  238. int        pico_nfcolor(char *);
  239. int        pico_nbcolor(char *);
  240. int        pico_rfcolor(char *);
  241. int        pico_rbcolor(char *);
  242. int        mswin_fflush (FILE *f);
  243. void        mswin_setperiodiccallback (callback_t periodiccb, 
  244.                     long period);
  245. WINHAND        mswin_inst2task (WINHAND hInst);
  246. int        mswin_ontask_del (WINHAND hTask, char *path);
  247. int        mswin_exec_and_wait (char *whatsit, char *command);
  248. void        mswin_exec_err_msg (char *what, int status, char *buf, 
  249.             int buflen);
  250. int        mswin_onexit_del (char *path);
  251. int        mswin_set_quit_confirm (int);
  252. void        mswin_showhelpmsg (WINHAND hWnd, char **helplines);
  253. int        mswin_displaytext (char *title, char *pText, size_t textLen, 
  254.             char **pLines, int windRef, int flags);
  255.  
  256. int        mswin_majorver();
  257. int        mswin_minorver();
  258. char           *mswin_compilation_date();
  259.  
  260.  
  261. int        mswin_usedialog (void);
  262. int        mswin_dialog (char *prompt, char *string, int field_len, 
  263.             int append_current, int passwd, 
  264.             MDlgButton *button_list, char **help, unsigned flags);
  265. int        mswin_select (char *prompt, MDlgButton *button_list, 
  266.             int dflt, int on_ctrl_C, char **help, unsigned flags);
  267. int        mswin_yesno (char *prompt);
  268.  
  269.  
  270. #ifdef    MSC_MALLOC
  271. /*
  272.  * These definitions will disable the SEGHEAP allocation routines, in
  273.  * favor of the compliler libraries usual allocators.  This is useful
  274.  * when external debugging tools and the SEGHEAP debugging routines step
  275.  * on each other...
  276.  */
  277. #define MemAlloc(X) malloc(X)
  278. #define MemFree(X) free(X)
  279. #define MemRealloc(X,Y) realloc(X,Y)
  280. #define MemFreeAll()
  281. #define    MemDebug(X,Y)
  282. #else
  283. /*
  284.  * Memory management stuff, from msmem.c
  285.  */
  286. typedef unsigned long        MemSize;
  287. typedef void __far          *    MemPtr;
  288.  
  289. #define MemAlloc(s)        _MemAlloc (s, __FILE__, __LINE__)
  290. #define malloc(s)        _MemAlloc (s, __FILE__, __LINE__)
  291. #define MemFree(b)        _MemFree (b, __FILE__, __LINE__)
  292. #define free(b)            _MemFree (b, __FILE__, __LINE__)
  293. #define MemRealloc(b,s)        _MemRealloc (b, s, __FILE__, __LINE__)
  294. #define realloc(b,s)        _MemRealloc (b, s, __FILE__, __LINE__)
  295. #define MEM_BLOCK_SIZE_MAX    0xff00
  296.  
  297. void        MemDebug (int debug, FILE *debugFile);
  298. void __far *    _MemAlloc (MemSize size, char __far * file, int line);
  299. int        _MemFree (void __far *block, char __far *file, int line);
  300. void __far *    _MemRealloc (void __far *block, MemSize size, 
  301.                     char __far * file, int line);
  302. MemSize        MemBlkSize (MemPtr block);
  303. void        MemFreeAll (void);
  304. void            MemFailSoon (MemSize);
  305. #endif
  306.  
  307.  
  308.  
  309. /*
  310.  * Signals that are not defined by MS C
  311.  */
  312. #define SIGHUP        1    /* Terminal hangup. */
  313. #define SIGINT      2   /* Ctrl-C sequence */
  314. #define SIGILL      4   /* illegal instruction - invalid function image */
  315. #define SIGSEGV     11  /* segment violation */
  316. #define SIGALRM     14  /* alarm clock */
  317. #define SIGTERM     15  /* Software termination signal from kill */
  318. #define SIGABRT     22  /* abnormal termination triggered by abort call */
  319. #define SIGWINCH    28    /* Change in window size. */
  320.  
  321.  
  322. #define fflush    mswin_fflush
  323.  
  324. #endif /* MSWIN_H */
  325.